<template>
 <div>
   <v-header></v-header>
   <div style="margin-top: 40px;">
   <div class="selectedAll2">
     <table class="selectedAll_tab2">
       <tr>
         <td>起始时间</td>
         <td>
           <input type="date" v-model="begintime" max="2027-09-23"/>
         </td>
         <td>结束时间</td>
         <td>
           <input type="date" v-model="endtime" max="2027-09-23"/>
         </td>
         <td>科室</td>
         <td>
           <select v-model="deptcode"  @change="getdapeName(deptcode)">
           <option v-for="dept in depts" :value="dept.code" >{{dept.name}}</option>
         </select>
         </td>
         <td >
           <button class="button btn_blur" @click="getRT()">查询</button>
           <button class="button btn_yellow" @click="excel()">导出excel</button>
         </td>
       </tr>
     </table>
   </div>

     <p v-show="timeShow" style="margin-left: 43px;">  日期：  {{begintime}}     <span style="margin-left: 50px;"> 科室：{{deptname}}</span></p>
     <p v-show="timeShow1" style="margin-left: 43px;">起始时间：{{begintime}}      结束时间： {{endtime}}     <span style="margin-left: 50px;"> 科室：{{deptname}}</span></p>
     <!--<p>科室：{{deptname}}</p>-->
   <div class="aList2">
     <table>
       <thead>
       <tr>
         <th>日期</th>
         <th>总列数</th>
         <th>阳性列数</th>
         <th>阴性列数</th>
         <th>阳性率</th>
       </tr>
       </thead>
       <tbody class="aList_body">
       <tr v-for="(p,index) in PositiveRates ">
         <td>{{p.date}}</td>
         <td>{{p.count}}</td>
         <td>{{p.yang}}</td>
         <td>{{p.yin}}</td>
         <td>{{p.bi}}%</td>
       </tr>
       </tbody>
     </table>
   </div>

   </div>

 </div>
</template>

<script>

  import Header from '@/components/Header/Header';


  export default {
    components: {
      'v-header': Header
    },

    created(){

      //查询所属科室  所属类型  isuse
      this.$http.get(window.localStorage.url + "/baseDept/getDepts") //遍历keshi isuse=1   正在使用的科室
        .then(function(res) {
          this.depts = res.data.data;
          this.deptcode=res.data.data[0].code;
          this.begintime = res.data.currenttime;
          this.endtime = res.data.currenttime;
          this.getdapeName(res.data.data[0].code);
//          console.log(res.data.currenttime);
        });

    },

    data() {


      return {
        msg: 'hello vue',
        //科室 科室code
        depts:"",
        deptcode:"",
      //起始时间 结束时间
        begintime:"",
        endtime:"",
       //查询得出的数据
        PositiveRates:"",
        timeShow:true,
      timeShow1:false,
//        科室名字
        deptname:"",
      }

      },



      methods: {
        getRT(){
//          console.log(this.begintime==this.endtime);

          if(this.begintime==this.endtime){

            this.timeShow=true;
            this.timeShow1=false;
          }else{

            this.timeShow1=true;
            this.timeShow=false;

          }


          console.log(this.begintime,this.endtime,this.deptcode);
          this.$http.get(window.localStorage.url + "/stat/getStatPositiveRate?begintime="+this.begintime+"&endtime="+this.endtime+"&deptcode="+this.deptcode)
            .then(function(res) {
            if(res.data.status=="SUCCESS"){
              this.PositiveRates=res.data.data;
//              console.log(res.data.data);
            }else{
              this.PositiveRates="";
            }
            });

        },

        getdapeName(code){
//          console.log(code);
          for(var i = 0; i < this.depts.length;i++){
            if( this.depts[i].code==code){
//              console.log( this.depts[i].code);
              this.deptname=this.depts[i].name;
            }
          }

//          this.deptname=deptname;
        },

        //导出excel
        excel(){
//          console.log("excel");
          $("iframe").remove();
          var iframe = document.createElement('iframe');
          iframe.src = localStorage.url+"/excel/ExcelPositiveRate?begintime="+this.begintime+"&endtime="+this.endtime+
            "&deptcode="+this.deptcode+"&deptname="+this.deptname;
          (iframe);
          $("body").append(iframe);
          $('iframe').css('display','none')
        },




      }

    }


</script>
<style scoped>
  .selectedAll2{
    min-width: 1300px;
    line-height: 40px;
    width: 100%;
    background: #fff;
  }
  .selectedAll_tab2{
    width: 94%;
    margin: 10px auto;
  }
  .selectedAll_tab2 tr td:nth-child(1),.selectedAll_tab2 tr td:nth-child(3),.selectedAll_tab2 tr td:nth-child(5){
    width: 7%;
    text-align: justify;
    text-align-last: justify;
    padding: 0 5px;
  }
  .selectedAll_tab2 tr td:nth-child(2){width: 18%;}
  .selectedAll_tab2 tr td:nth-child(4){width: 18%;}
  .selectedAll_tab2 tr td:nth-child(6){width: 18%;}
  .selectedAll_tab2 tr td:nth-child(7){width: 25%;}
  .selectedAll_tab2 input,.selectedAll_tab2 select{
    width: 80%;
  }
  .selectedAll_tab2 button{
    width: 30%;
    margin: 0 5%;
    padding: 4px 20px;
  }


  .aList2{
    width: 98%;
    margin: 0 auto;
    line-height: 36px;
    min-width: 1300px;
  }
  .aList2 table{
    background: #fff;
  }
  .aList2 tr th{
    background: #999;
    color: #fff;
  }
  .aList2 tr td,.AllList tr th{
    border: 1px solid #ddd;
    text-align: center;
  }
  .aList2 table input[type=checkbox]{
    position: relative;
    top: 5px;
    cursor: pointer;
  }

</style>
